package org.csu.mypetstorecmsapi.persistence;

import jakarta.transaction.Transactional;
import org.csu.mypetstorecmsapi.domain.Inventory;
import org.csu.mypetstorecmsapi.domain.Item;
import org.csu.mypetstorecmsapi.domain.Product;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface InventoryDao extends JpaRepository<Inventory, Integer> {
    @Transactional
    @Modifying
    @Query(value = "delete from inventory where itemid =?1", nativeQuery = true)
    void deleteByItemId(String itemId);

    @Query(value = "select * from inventory where itemid =?1 limit 1", nativeQuery = true)
    Inventory findByItemId(String itemId);
}
